<% content_for :title, "Scenarios" -%>

<div class='container'>
  <div class='row'>
    <div class='col-md-12'>
      <div class="page-header">
        <h2>
          Your Scenarios
        </h2>
      </div>

      <blockquote>Scenarios are named groups of Agents.  Scenarios allow you to organize your agents,
        and to import and export sets of Agents to share.</blockquote>

      <table class='table table-striped'>
        <tr>
          <th><%= sortable_column 'name', 'asc' %></th>
          <th>Agents</th>
          <th><%= sortable_column 'public' %></th>
          <th></th>
        </tr>

        <% @scenarios.each do |scenario| %>
          <tr>
            <td>
              <%= scenario_label(scenario, icon('fa-solid', scenario.icon.presence || 'gear'))%>
              <%= link_to(scenario.name, scenario) %>
            </td>
            <td><%= link_to pluralize(scenario.agents.count, "agent"), scenario %></td>
            <td><%= scenario.public? ? "yes" : "no" %></td>
            <td>
              <div class="btn-group btn-group-xs" style="float: right">
                <%= link_to 'Show', scenario, class: "btn btn-default" %>
                <%= link_to 'Edit', edit_scenario_path(scenario), class: "btn btn-default" %>
                <%= link_to 'Share', share_scenario_path(scenario), class: "btn btn-default" %>
                <%= link_to 'Delete', '#', data: { toggle: 'modal', target: "#confirm-scenario-deletion-#{scenario.id}"}, class: "btn btn-default" %>
              </div>
              <%= render 'scenarios/confirm_deletion_modal', scenario: scenario %>
            </td>
          </tr>
        <% end %>
      </table>

      <%= paginate @scenarios, :theme => 'twitter-bootstrap-3' %>

      <br/>

      <div class="btn-group">
        <%= link_to icon_tag('glyphicon-plus') + ' New Scenario'.html_safe, new_scenario_path, class: "btn btn-default" %>
        <%= link_to icon_tag('glyphicon-cloud-upload') + ' Import Scenario'.html_safe, new_scenario_imports_path, class: "btn btn-default" %>
      </div>
    </div>
  </div>
</div>
